#pragma once

#ifndef __MOUSE__DRAG__INCLUDED__HH__
#define __MOUSE__DRAG__INCLUDED__HH__
#include <Qt/qmouse_qws.h>
#include <qpoint.h>

struct MouseDrag
{
	bool Dragging;
	QPoint Start, StartRefreshed;
	QPoint End;
	QPoint Delta, DeltaRefreshed;

	MouseDrag()
		: Dragging(false){}
	~MouseDrag(){}

	void mousePressed( const QPoint &pos, Qt::MouseButtons )
	{
		Dragging = true;
		End = Start = StartRefreshed = pos;
		
		Delta = DeltaRefreshed = QPoint();
	}
	void mouseMoved( const QPoint &pos, Qt::MouseButtons buttons )
	{
		if( !Dragging ){ 
			(void)pos; 
			(void)buttons; 
			return; 
		}
		End = pos;
		DeltaRefreshed = End - StartRefreshed;
		Delta = End-Start;
		StartRefreshed = pos;
	}
	void mouseReleased( const QPoint &pos, Qt::MouseButtons )
	{
		Dragging = false;
		End = pos;
		DeltaRefreshed = End - StartRefreshed;
		Delta = End-Start;
	}
};

#endif